// 注意：这个文件是冗余的，不再使用
// 原因：此文件使用Travel.js模型，但前端实际使用的是Tour模型
// 项目现在使用init-tour-data.js来初始化数据

const mongoose = require('mongoose');
require('dotenv').config();
const {
  Strategy,
  LocalTour,
  FreeTour,
  GroupTour,
  Hotel,
  VisaService
} = require('./models/Travel');

// 攻略数据
const strategiesData = [
  {
    title: '圣托里尼完美3天2夜攻略',
    description: '带你玩转圣托里尼，体验最美的日落和蓝白小镇',
    content: '圣托里尼岛位于爱琴海，以其蓝白相间的建筑和壮丽的日落而闻名...',
    destination: '圣托里尼',
    images: ['assets/photo/2.jpg'],
    tags: ['海岛', '日落', '蜜月', '摄影'],
    views: 1520,
    likes: 89,
    difficulty: '简单',
    duration: '3天2夜',
    budget: 3500,
    season: ['春季', '夏季', '秋季']
  },
  {
    title: '雅典历史文化深度游',
    description: '探索古希腊文明的发源地，领略历史的厚重',
    content: '雅典是西方文明的摇篮，这里有帕特农神庙、卫城博物馆...',
    destination: '雅典',
    images: ['assets/photo/4.jpg'],
    tags: ['历史', '文化', '博物馆', '古迹'],
    views: 987,
    likes: 67,
    difficulty: '中等',
    duration: '2天1夜',
    budget: 2200,
    season: ['春季', '秋季', '冬季']
  },
  {
    title: '米克诺斯岛party指南',
    description: '欧洲最佳party圣地，享受无尽的夜生活',
    content: '米克诺斯岛不仅有美丽的海滩，更是著名的派对天堂...',
    destination: '米克诺斯',
    images: ['assets/photo/5.jpg'],
    tags: ['派对', '海滩', '夜生活', '音乐'],
    views: 2340,
    likes: 156,
    difficulty: '简单',
    duration: '4天3夜',
    budget: 4200,
    season: ['夏季']
  }
];

// 当地游数据
const localToursData = [
  {
    title: '圣托里尼日落游船体验',
    description: '乘坐游船欣赏世界最美日落，包含晚餐和香槟',
    destination: '圣托里尼',
    price: 280,
    originalPrice: 350,
    images: ['assets/photo/2.jpg'],
    duration: '3小时',
    groupSize: 12,
    includeServices: ['游船', '晚餐', '香槟', '导游'],
    highlights: ['世界最美日落', '浪漫晚餐', '火山景观'],
    rating: 4.9,
    reviewCount: 342,
    bookingCount: 856,
    provider: '圣托里尼海上旅游公司',
    isPopular: true
  },
  {
    title: '雅典卫城VIP导览',
    description: '专业考古学家带领，深度解读古希腊文明',
    destination: '雅典',
    price: 120,
    originalPrice: 160,
    images: ['assets/photo/4.jpg'],
    duration: '2小时',
    groupSize: 8,
    includeServices: ['专业导游', '门票', '耳机', '小册子'],
    highlights: ['专业讲解', '小团体验', '跳过排队'],
    rating: 4.8,
    reviewCount: 198,
    bookingCount: 445,
    provider: '雅典文化遗产公司',
    isPopular: true
  },
  {
    title: '米克诺斯海滩跳岛游',
    description: '一日畅游多个绝美海滩，含午餐和交通',
    destination: '米克诺斯',
    price: 95,
    originalPrice: 120,
    images: ['assets/photo/5.jpg'],
    duration: '全天',
    groupSize: 20,
    includeServices: ['交通', '午餐', '海滩椅', '浮潜设备'],
    highlights: ['多个海滩', '水上活动', '美食体验'],
    rating: 4.7,
    reviewCount: 267,
    bookingCount: 623,
    provider: '米克诺斯海岛探索',
    isPopular: false
  }
];

// 自由行数据
const freeToursData = [
  {
    title: '希腊双岛自由行 - 圣托里尼+米克诺斯',
    description: '5天4夜双岛体验，机票+酒店+接送机全包',
    destination: '圣托里尼+米克诺斯',
    price: 4580,
    originalPrice: 5200,
    images: ['assets/photo/2.jpg', 'assets/photo/5.jpg'],
    duration: '5天4夜',
    flightIncluded: true,
    hotelIncluded: true,
    hotelLevel: '豪华型',
    flightType: '经济舱',
    highlights: ['两大热门岛屿', '海景酒店', '轮渡包含', '24小时客服'],
    itinerary: [
      { day: 1, title: '抵达圣托里尼', activities: ['接机', '酒店入住', '自由活动'] },
      { day: 2, title: '圣托里尼全天', activities: ['伊亚小镇', '蓝顶教堂', '日落观赏'] },
      { day: 3, title: '圣托里尼-米克诺斯', activities: ['轮渡前往', '风车群', '小威尼斯'] },
      { day: 4, title: '米克诺斯海滩日', activities: ['天堂海滩', '水上运动', '海鲜大餐'] },
      { day: 5, title: '返程', activities: ['自由购物', '送机', '回国'] }
    ],
    rating: 4.8,
    reviewCount: 156,
    bookingCount: 289,
    isPopular: true
  },
  {
    title: '雅典+圣托里尼经典组合',
    description: '6天5夜经典搭配，历史文化+浪漫海岛',
    destination: '雅典+圣托里尼',
    price: 3980,
    originalPrice: 4500,
    images: ['assets/photo/4.jpg', 'assets/photo/2.jpg'],
    duration: '6天5夜',
    flightIncluded: true,
    hotelIncluded: true,
    hotelLevel: '舒适型',
    flightType: '经济舱',
    highlights: ['古典与浪漫', '内陆航班', '市中心酒店', '自由度高'],
    itinerary: [
      { day: 1, title: '抵达雅典', activities: ['接机', '酒店入住', '普拉卡老区'] },
      { day: 2, title: '雅典古迹游', activities: ['卫城', '古代市集', '国家考古博物馆'] },
      { day: 3, title: '雅典-圣托里尼', activities: ['内陆航班', '酒店入住', '费拉小镇'] },
      { day: 4, title: '圣托里尼北部', activities: ['伊亚小镇', '蓝顶教堂', '日落晚餐'] },
      { day: 5, title: '圣托里尼南部', activities: ['红海滩', '黑海滩', '酒庄参观'] },
      { day: 6, title: '返程', activities: ['自由时间', '送机', '回国'] }
    ],
    rating: 4.7,
    reviewCount: 203,
    bookingCount: 445,
    isPopular: true
  }
];

// 跟团游数据
const groupToursData = [
  {
    title: '希腊三岛经典7日游',
    description: '雅典+圣托里尼+米克诺斯，含全程导游和餐食',
    destination: '雅典+圣托里尼+米克诺斯',
    price: 5680,
    originalPrice: 6200,
    images: ['assets/photo/4.jpg', 'assets/photo/2.jpg', 'assets/photo/5.jpg'],
    duration: '7天6夜',
    groupSize: 25,
    minGroupSize: 16,
    includeServices: ['往返机票', '酒店住宿', '三餐', '景点门票', '中文导游', '旅游巴士'],
    excludeServices: ['个人消费', '小费', '自费项目'],
    tourGuide: true,
    tourGuideLanguage: ['中文', '英文'],
    itinerary: [
      { day: 1, title: '出发-雅典', activities: ['抵达雅典', '接机', '酒店入住'], meals: ['晚餐'], accommodation: '雅典4星酒店' },
      { day: 2, title: '雅典古迹', activities: ['卫城', '宙斯神庙', '市区观光'], meals: ['早餐', '午餐', '晚餐'], accommodation: '雅典4星酒店' },
      { day: 3, title: '雅典-圣托里尼', activities: ['内陆航班', '费拉小镇'], meals: ['早餐', '午餐', '晚餐'], accommodation: '圣托里尼海景酒店' },
      { day: 4, title: '圣托里尼全天', activities: ['伊亚小镇', '蓝顶教堂', '日落观赏'], meals: ['早餐', '午餐', '晚餐'], accommodation: '圣托里尼海景酒店' },
      { day: 5, title: '圣托里尼-米克诺斯', activities: ['轮渡', '风车群', '小威尼斯'], meals: ['早餐', '午餐', '晚餐'], accommodation: '米克诺斯海景酒店' },
      { day: 6, title: '米克诺斯-雅典', activities: ['轮渡返回', '自由购物'], meals: ['早餐', '午餐'], accommodation: '雅典机场酒店' },
      { day: 7, title: '返程', activities: ['送机', '回国'], meals: ['早餐'], accommodation: '无' }
    ],
    departureCity: '北京',
    departureDates: [
      new Date('2025-07-15'),
      new Date('2025-08-01'),
      new Date('2025-08-15'),
      new Date('2025-09-01')
    ],
    rating: 4.6,
    reviewCount: 89,
    bookingCount: 156,
    tourOperator: '环球希腊之旅',
    isPopular: true
  }
];

// 酒店数据
const hotelsData = [
  {
    name: '圣托里尼悬崖海景酒店',
    description: '位于伊亚悬崖边的豪华酒店，享受无敌海景和日落',
    destination: '圣托里尼',
    address: '伊亚镇悬崖路1号',
    location: {
      latitude: 36.4618,
      longitude: 25.3753,
      city: '圣托里尼',
      country: '希腊'
    },
    images: ['assets/photo/2.jpg'],
    starRating: 5,
    rating: 4.9,
    reviewCount: 445,
    priceRange: { min: 800, max: 2000, currency: 'CNY' },
    roomTypes: [
      { type: '标准海景房', price: 800, maxGuests: 2, amenities: ['海景阳台', '免费WiFi', '空调'] },
      { type: '豪华套房', price: 1200, maxGuests: 2, amenities: ['私人泳池', '海景阳台', '管家服务'] },
      { type: '总统套房', price: 2000, maxGuests: 4, amenities: ['超大私人泳池', '全海景', '24小时管家'] }
    ],
    hotelAmenities: ['无边泳池', '健身房', '水疗中心', '餐厅', '酒吧', '免费WiFi', '24小时前台'],
    policies: {
      checkIn: '15:00',
      checkOut: '11:00',
      cancellation: '入住前48小时可免费取消',
      pets: false
    },
    contact: {
      phone: '+30-22860-71234',
      email: 'info@santorinicliff.com',
      website: 'www.santorinicliff.com'
    },
    isPopular: true,
    bookingCount: 234
  },
  {
    name: '雅典卫城精品酒店',
    description: '位于雅典市中心，步行可达卫城和各大景点',
    destination: '雅典',
    address: '普拉卡区中央街道15号',
    location: {
      latitude: 37.9755,
      longitude: 23.7348,
      city: '雅典',
      country: '希腊'
    },
    images: ['assets/photo/4.jpg'],
    starRating: 4,
    rating: 4.6,
    reviewCount: 567,
    priceRange: { min: 300, max: 800, currency: 'CNY' },
    roomTypes: [
      { type: '标准双人房', price: 300, maxGuests: 2, amenities: ['城市景观', '免费WiFi', '空调'] },
      { type: '卫城景观房', price: 500, maxGuests: 2, amenities: ['卫城景观', '阳台', '迷你吧'] },
      { type: '豪华套房', price: 800, maxGuests: 3, amenities: ['卫城全景', '独立客厅', 'VIP服务'] }
    ],
    hotelAmenities: ['屋顶餐厅', '健身房', '商务中心', '洗衣服务', '免费WiFi', '24小时前台'],
    policies: {
      checkIn: '14:00',
      checkOut: '12:00',
      cancellation: '入住前24小时可免费取消',
      pets: true
    },
    contact: {
      phone: '+30-210-123-4567',
      email: 'info@athensacropolis.com',
      website: 'www.athensacropolis.com'
    },
    isPopular: true,
    bookingCount: 389
  }
];

// 签证服务数据
const visaServicesData = [
  {
    country: '希腊',
    visaType: '旅游签证',
    title: '希腊申根旅游签证办理',
    description: '专业办理希腊申根签证，出签率高，服务周到',
    price: 580,
    processingTime: '10-15个工作日',
    validityPeriod: '按申请时间',
    stayDuration: '最长90天',
    entryTimes: '多次入境',
    requiredDocuments: [
      '护照原件及复印件',
      '签证申请表',
      '照片2张',
      '行程单',
      '机票预订单',
      '酒店预订单',
      '银行流水',
      '在职证明',
      '保险单'
    ],
    serviceIncludes: [
      '材料审核',
      '预约递交',
      '表格填写',
      '进度跟踪',
      '代取护照',
      '签证指导'
    ],
    successRate: 98,
    urgentService: true,
    urgentPrice: 880,
    urgentTime: '5-8个工作日',
    provider: '环球签证服务中心',
    rating: 4.9,
    reviewCount: 1234,
    orderCount: 3456,
    isPopular: true
  },
  {
    country: '希腊',
    visaType: '商务签证',
    title: '希腊申根商务签证办理',
    description: '专业办理希腊商务签证，适合商务出行',
    price: 680,
    processingTime: '10-15个工作日',
    validityPeriod: '按申请时间',
    stayDuration: '最长90天',
    entryTimes: '多次入境',
    requiredDocuments: [
      '护照原件及复印件',
      '签证申请表',
      '照片2张',
      '邀请函',
      '机票预订单',
      '酒店预订单',
      '银行流水',
      '营业执照',
      '保险单'
    ],
    serviceIncludes: [
      '材料审核',
      '预约递交',
      '表格填写',
      '进度跟踪',
      '代取护照',
      '商务指导'
    ],
    successRate: 96,
    urgentService: true,
    urgentPrice: 980,
    urgentTime: '5-8个工作日',
    provider: '环球签证服务中心',
    rating: 4.7,
    reviewCount: 456,
    orderCount: 892,
    isPopular: false
  }
];

async function initTravelData() {
  try {
    // 连接数据库
    await mongoose.connect(process.env.MONGODB_URI || 'mongodb://localhost:27017/traveller_social_app', {
      useNewUrlParser: true,
      useUnifiedTopology: true
    });

    console.log('✅ 数据库连接成功');

    // 清空现有数据
    await Strategy.deleteMany({});
    await LocalTour.deleteMany({});
    await FreeTour.deleteMany({});
    await GroupTour.deleteMany({});
    await Hotel.deleteMany({});
    await VisaService.deleteMany({});

    console.log('🗑️ 清除现有旅行数据');

    // 插入新数据
    const strategies = await Strategy.insertMany(strategiesData);
    console.log(`✅ 创建 ${strategies.length} 个攻略`);

    const localTours = await LocalTour.insertMany(localToursData);
    console.log(`✅ 创建 ${localTours.length} 个当地游`);

    const freeTours = await FreeTour.insertMany(freeToursData);
    console.log(`✅ 创建 ${freeTours.length} 个自由行套餐`);

    const groupTours = await GroupTour.insertMany(groupToursData);
    console.log(`✅ 创建 ${groupTours.length} 个跟团游`);

    const hotels = await Hotel.insertMany(hotelsData);
    console.log(`✅ 创建 ${hotels.length} 个酒店`);

    const visaServices = await VisaService.insertMany(visaServicesData);
    console.log(`✅ 创建 ${visaServices.length} 个签证服务`);

    console.log('\n🎉 旅行数据初始化完成！');
    console.log('\n📋 数据统计:');
    console.log(`   📝 攻略: ${strategies.length} 个`);
    console.log(`   🚶 当地游: ${localTours.length} 个`);
    console.log(`   ✈️ 自由行: ${freeTours.length} 个`);
    console.log(`   👥 跟团游: ${groupTours.length} 个`);
    console.log(`   🏨 酒店: ${hotels.length} 个`);
    console.log(`   📋 签证服务: ${visaServices.length} 个`);

  } catch (error) {
    console.error('❌ 初始化失败:', error);
  } finally {
    await mongoose.connection.close();
    console.log('👋 数据库连接已关闭');
    process.exit(0);
  }
}

// 运行初始化
if (require.main === module) {
  initTravelData();
}

module.exports = { initTravelData }; 